from ding_talk import app
from ding_talk.sdk_helper import send_message


@app.task(ignore_result=True)
def notify_dev():
    webhook = 'https://oapi.dingtalk.com/robot/send?access_token=ed4612dc06fee3b0b2b27c54ccaaa2d1ae75c5cc035698a85387a25387856069'  # 钉钉机器人webhook
    secret = 'SEC622dc25995c20a351c5d90386e236b9b6acdeed5698772705f9c14e22d68ec68'  # 钉钉机器人秘钥
    message_list = [
        '[专注]<font size=8 face="黑体">**代办事务提醒**</font>[专注]\n'
        "1. 请值班人员及时创建周会语雀，[语雀地址](https://hellobike.yuque.com/zm6w0n/fcr61o/vvn4rkd14uh3wf55)，相应的代办项请对应人员及时补充[送花花][送花花]\n",
        "2. 请相应人员及时补充每周性能分析[送花花][送花花]\n",
        "3. 所有人及时填写测试发布checklist [送花花][送花花] \n"
    ]
    data = {
        "msgtype": "markdown",
        "markdown": {
            "title": "代办事务提醒",
            "text": "".join(message_list),
        },
        "at": {
            "isAtAll": True
        }
    }
    print(send_message(webhook, secret, data))


@app.task(ignore_result=True)
def notify_prod():
    webhook = 'https://oapi.dingtalk.com/robot/send?access_token=d1617ae244c69648a29d6852eb6276d26ca186721b533e36df8e7e0a8f919cf3'  # 钉钉机器人webhook
    secret = 'SECad58b8f862a62a21ca9ce55c4f485051cede9fcb0a8bfe3979348752f53a4845'  # 钉钉机器人秘钥
    message_list = [
        '[专注]<font size=8 face="黑体">**代办事务提醒**</font>[专注]\n'
        "1. 请值班人员及时创建周会语雀，[语雀地址](https://hellobike.yuque.com/zm6w0n/fcr61o/vvn4rkd14uh3wf55)，相应的代办项请对应人员及时补充[送花花][送花花]\n",
        "2. 请相应人员及时补充每周性能分析[送花花][送花花]\n",
        "3. 所有人及时填写测试发布checklist [送花花][送花花] \n"
    ]
    data = {
        "msgtype": "markdown",
        "markdown": {
            "title": "代办事务提醒",
            "text": "".join(message_list),
        },
        "at": {
            "isAtAll": True
        }
    }
    print(send_message(webhook, secret, data))


if __name__ == '__main__':
    notify_dev()
